
<%@page contentType="text/html" pageEncoding="UTF-8"%>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"
    "http://www.w3.org/TR/html4/loose.dtd">
<%@page import="java.util.*,Beans.ThamSoHT,Models.ThamSoHT_Model, Models.KhuVuc_Model, Models.DauBep_Model, Models.MonAn_Model, Models.DonViTinh_Model, Models.TuyChon_Model"%>

<script type="text/javascript">
    function keypress(e){
        //Hàm dùng để ngăn người dùng nhập các ký tự khác ký tự số vào TextBox
        var keypressed = null;
        if (window.event)
        {
            keypressed = window.event.keyCode; //IE
        }
        else
        {
            keypressed = e.which; //NON-IE, Standard
        }
        if (keypressed < 48 || keypressed > 57 )
        { //CharCode của 0 là 48 (Theo bảng mã ASCII)
            //CharCode của 9 là 57 (Theo bảng mã ASCII)
            if (keypressed == 8 || keypressed == 127  )
            {//Phím Delete và Phím Back
                return;
            }
            return false;
        }
    }
</script>
<script type="text/javascript">
    $().ready(function() {
        $('select.makv').click(function(){
            clearInterval(id);
            id = null;
        });
        $('select.mattma').click(function(){
            clearInterval(id);
            id = null;
        });
        var sx1 = document.getElementById("SortNgayGioCook").alt;
        var sx2 = document.getElementById("SortKVCook").alt;
        var sx3 = document.getElementById("SortBanCook").alt;
        var sx4 = document.getElementById("SortMACook").alt;
        var sx5 = document.getElementById("SortDVTCook").alt;
        var sx6 = document.getElementById("SortSLCook").alt;
        $('#titledskv1').click(function(){
            document.getElementById("SortNgayGioCook").value = "true";
            if(sx1 == "desc"){
                document.getElementById("SortNgayGioCook").alt = "asc";                
            }
            else{
                document.getElementById("SortNgayGioCook").alt = "desc";                
            }
        });
        $('#titledskv2').click(function(){            
            document.getElementById("SortKVCook").value = "true";
            if(sx2 == "desc"){
                document.getElementById("SortKVCook").alt = "asc";
            }
            else{
                document.getElementById("SortKVCook").alt = "desc";
            }
        });
        $('#titledskv3').click(function(){            
            document.getElementById("SortBanCook").value = "true";
            if(sx3 == "desc"){
                document.getElementById("SortBanCook").alt = "asc";
            }
            else{
                document.getElementById("SortBanCook").alt = "desc";
            }
        });
        $('#titledskv4').click(function(){            
            document.getElementById("SortMACook").value = "true";
            if(sx4 == "desc"){
                document.getElementById("SortMACook").alt = "asc";
            }
            else{
                document.getElementById("SortMACook").alt = "desc";
            }
        });
        $('#titledskv5').click(function(){
            document.getElementById("SortDVTCook").value = "true";
            if(sx5 == "desc"){
                document.getElementById("SortDVTCook").alt = "asc";
            }
            else{
                document.getElementById("SortDVTCook").alt = "desc";
            }
        });
        $('#titledskv6').click(function(){
            document.getElementById("SortSLCook").value = "true";
            if(sx6 == "desc"){
                document.getElementById("SortSLCook").alt = "asc";
            }
            else{
                document.getElementById("SortSLCook").alt = "desc";
            }
        });
    });
    
</script>
<%
            int langid = (Integer) session.getAttribute("langid"); // ngôn ngữ hiện tại
            String dsts = " 'print', 'all', 'nofood', 'notice', 'notes', 'quantity', 'status', 'rightmsg', 'order', 'unit', 'food', 'table', 'area', 'timehistory', 'foodlist' ";
            ThamSoHT[] mdsts = ThamSoHT_Model.DSThamSo(dsts, langid); // mảng chứa các tham số của trang này.

            String all = mdsts[0].getTenTS();
            String area = mdsts[1].getTenTS();
            String food = mdsts[2].getTenTS();
            String foodlist = mdsts[3].getTenTS();
            String nofood = mdsts[4].getTenTS();
            String notes = mdsts[5].getTenTS();
            String notice = mdsts[6].getTenTS();
            String order = mdsts[7].getTenTS();
            String print = mdsts[8].getTenTS();
            String quantity = mdsts[9].getTenTS();
            String rightmsg = mdsts[10].getTenTS();
            String status = mdsts[11].getTenTS();
            String table = mdsts[12].getTenTS();
            String timehistory = mdsts[13].getTenTS();
            String unit = mdsts[14].getTenTS();

            String msgright = notice + "/" + rightmsg;
            Vector v = (Vector) request.getAttribute("DSMA");
            Vector vkv = (Vector) request.getAttribute("DSKV");
            Vector vDSTTMA = (Vector) request.getAttribute("DSTTMA");
            String count = (String) request.getAttribute("count");
            String ng = (String) request.getAttribute("ng");
            String khuvucc = (String) request.getAttribute("kv");
            String ban = (String) request.getAttribute("b");
            String ma = (String) request.getAttribute("ma");
            String dvt = (String) request.getAttribute("dvt");
            String sl = (String) request.getAttribute("sl");            
            String ud1 = (String) request.getAttribute("ud1");
            String ud2 = (String) request.getAttribute("ud2");
            String ud3 = (String) request.getAttribute("ud3");
            String ud4 = (String) request.getAttribute("ud4");
            String ud5 = (String) request.getAttribute("ud5");
            String ud6 = (String) request.getAttribute("ud6");
            String makv = (String) request.getAttribute("makv");
            String tenban = (String) request.getAttribute("tenban");
            String tenma = (String) request.getAttribute("tenma");
            String tendvt = (String) request.getAttribute("tendvt");
            String soluong = (String) request.getAttribute("soluong");
            String mattma = (String) request.getAttribute("mattma");
            String sx1 = "";
            String sx2 = "";
            String sx3 = "";
            String sx4 = "";
            String sx5 = "";
            String sx6 = "";
            if(ud1.equals("asc")){
                sx1 = "up1";
            }
            else{
                sx1 = "down1";
            }
            if(ud2.equals("asc")){
                sx2 = "up1";
            }
            else{
                sx2 = "down1";
            }
            if(ud3.equals("asc")){
                sx3 = "up1";
            }
            else{
                sx3 = "down1";
            }
            if(ud4.equals("asc")){
                sx4 = "up1";
            }
            else{
                sx4 = "down1";
            }
            if(ud5.equals("asc")){
                sx5 = "up1";
            }
            else{
                sx5 = "down1";
            }
            if(ud6.equals("asc")){
                sx6 = "up1";
            }
            else{
                sx6 = "down1";
            }

            int total = 0;
%>

<form name="frmcookk" id="frmcookk" action="" >
    <div class="title">
        <%=foodlist%>
        <a onclick="InPhieuCook()" title="<%=print%>" style="float: right; margin-top: 1px; cursor: pointer;" lang="<%=msgright%>"><img style="height: 32px; width: 32px; " alt="" src="../images/print.png"></a>
        <div onclick="Cook3()" lang="<%=msgright%>" id="3" style="float: right;margin-top: 6px; " class="ttmacook ttmacook3" title="<%=DauBep_Model.LayTenTTMA("3", langid)%>"></div>
        <div id="hoithuc" style="float: right;margin-top: -1px; margin-right: 20px; position: relative;">
        <%  if(count.equals("0")){%>
                <img style=" height: 28px; width: 32px; cursor: pointer; opacity: 0.4; margin-top: 3px;" alt="" src="../images/hoithuc.png">
        <%  }
            else{%>
                <div class = 'hoithuc' onclick='ShowHoiThuc()'><%=count%></div>
                <div id="rshoithuc">
                <%
                    Vector vDSHoiThuc = (Vector) request.getAttribute("DSHoiThuc");
                    for(int i=0; i<vDSHoiThuc.size(); i++){
                        Beans.DauBep bb = (Beans.DauBep) vDSHoiThuc.elementAt(i);%>
                        <div class="mahoithuc"><%=bb.getTenMA() %></div>
                        <div class="tthoithuc"><div onclick="UpdateTTMACook(this.align, this.id, this.lang)" align="<%=bb.getMaCTHDT()%>" lang="<%=msgright%>" id="2" style=" float: left; margin-right: 0px; border-color: #1c1c1c; height: 20px; width: 20px;" class="ttmacook ttmacook2" title="<%=DauBep_Model.LayTenTTMA("2", langid)%>" ></div></div>
                        <div onclick="BoQuaHoiThuc(this.align, this.lang)" align="<%=bb.getMaCTHDT()%>" lang="<%=msgright%>" style=" margin-right: 0px; height: 20px; width: 30px; float: left; cursor: pointer; border-top: 1px solid #959494;"><img style=" height: 20px; width: 20px; margin-top: 7px;" alt="" src="../images/del1.png"></div>
                <%  }%>
                </div>
        <%  }%>
        </div>
        <div style="float: right;margin-top: 2px; margin-right: 20px;"><img style=" height: 30px; width: 30px; cursor: pointer; opacity: 0.3;" alt="" src="../images/chat.png"></div>
    </div>
    <div class="content">
        <table class="mytable" border="0" cellpadding="0" cellspacing="0">
            <thead>
                <tr>
                    <th style="width: 4%;  "><%=order%></th>
                    <th style="width: 11%; ">
                        <a href="#" id="titledskv1" style="margin-top: 5px;"  >
                            <div style="float:left"><%=timehistory%></div>
                            <div id="sortkv1" style=" margin-right: 30px;" class="<%=sx1%>" ></div>
                        </a>
                    </th>
                    <th style="width: 10%; ">
                        <a href="#" id="titledskv2" style="margin-top: 5px;" >
                            <div style="float:left"><%=area%></div>
                            <div id="sortkv2" style=" margin-right: 30px;" class="<%=sx2%>"></div>
                        </a>
                    </th>
                    <th style="width: 7%; ">
                        <a href="#" id="titledskv3" style="margin-top: 5px;"  >
                            <div style="float:left"><%=table%></div>
                            <div id="sortkv3" style=" margin-right: 25px;" class="<%=sx3%>"></div>
                        </a>
                    </th>
                    <th style="width: 16%; ">
                        <a href="#" id="titledskv4" style="margin-top: 5px;" >
                            <div style="float:left"><%=food%></div>
                            <div id="sortkv4" style=" margin-right: 60px;" class="<%=sx4%>"></div>
                        </a>
                    </th>
                    <th style="width: 10%; ">
                        <a href="#" id="titledskv5" style="margin-top: 5px;" >
                            <div style="float:left"><%=unit%></div>
                            <div id="sortkv5" style=" margin-right: 15px;" class="<%=sx5%>"></div>
                        </a>
                    </th>
                    <th style="width: 9%; ">
                        <a href="#" id="titledskv6" style="margin-top: 5px;" >
                            <div style="float:left"><%=quantity%></div>
                            <div id="sortkv6" style=" margin-right: 20px;" class="<%=sx6%>"></div>
                        </a>
                    </th>
                    <th style="width: 19%; ">
                        <a href="#" id="titledskv7" style="margin-top: 5px;" >
                            <div style="float:left"><%=notes%></div>
                        </a>
                    </th>
                    <th style=" ">
                        <a href="#" id="titledskv8" style="margin-top: 5px;">
                            <div style="float:left"><%=status%></div>
                        </a>
                    </th>
                </tr>
                <tr id="searchCook">
                    <th><img alt="" style=" margin-top: 2px; margin-left: 3px; margin-bottom: -7px; cursor: pointer;" lang="<%=msgright%>" src="../images/search1.png" onclick="CookInteval()"></th>
                    <th></th>
                    <th>
                        <select class="makv" onchange="CookInteval()"  lang="<%=msgright%>" >
                            <%
                                        if (makv.equals("all")) {%>
                            <option value="all"><%=all%></option>
                            <%
                                                                            for (int k = 0; k < vkv.size(); k++) {
                                                                                Beans.KhuVuc khuvuc = (Beans.KhuVuc) vkv.elementAt(k);%>
                            <option value="<%=khuvuc.getMaKV()%>"><%=khuvuc.getTenKV()%></option>
                            <%      }%>

                            <%  } else {%>
                            <option value="<%=makv%>"><%=Models.Ban_Model.LayTenKV(Integer.parseInt(makv), langid)%></option>
                            <%
                                                                            KhuVuc_Model kvv = new KhuVuc_Model();
                                                                            Vector vkhuvuc = new Vector();
                                                                            vkhuvuc = kvv.LayDSKVDB(Integer.parseInt(makv), langid);
                                                                            for (int i = 0; i < vkhuvuc.size(); i++) {
                                                                                Beans.KhuVuc kv = (Beans.KhuVuc) vkhuvuc.elementAt(i);%>
                            <option value="<%=kv.getMaKV()%>"><%=kv.getTenKV()%></option>
                            <%  }%>
                            <option value="all"><%=all%></option>
                            <%  }%>
                        </select>
                    </th>
                    <th><input value="<%=tenban%>" type="textbox" style="width: 50px;" class="text tenban"  onkeypress="return keypress(event)"></th>
                    <th><input value="<%=tenma%>" type="textbox" style="width: 130px;" class="text tenma" ></th>
                    <th><input value="<%=tendvt%>" type="textbox" style="width: 90px;" class="text tendvt" ></th>
                    <th><input value="<%=soluong%>" type="textbox" style="width: 50px;" class="text soluong" onkeypress="return keypress(event)"></th>
                    <th></th>
                    <th>
                        <select class="mattma" onchange="CookInteval()"  lang="<%=msgright%>" >
                            <%
                                        if (mattma.equals("1")) {%>
                            <option value="1"><%=DauBep_Model.LayTenTTMA("1", langid)%></option>
                            <option value="2"><%=DauBep_Model.LayTenTTMA("2", langid)%></option>
                            <option value="3"><%=DauBep_Model.LayTenTTMA("3", langid)%></option>
                            <option value="all"><%=all%></option>
                            <%    } else if (mattma.equals("2")) {%>
                            <option value="2"><%=DauBep_Model.LayTenTTMA("2", langid)%></option>
                            <option value="1"><%=DauBep_Model.LayTenTTMA("1", langid)%></option>
                            <option value="3"><%=DauBep_Model.LayTenTTMA("3", langid)%></option>
                            <option value="all"><%=all%></option>
                            <%  } else if (mattma.equals("3")) {%>
                            <option value="3"><%=DauBep_Model.LayTenTTMA("3", langid)%></option>
                            <option value="2"><%=DauBep_Model.LayTenTTMA("2", langid)%></option>
                            <option value="1"><%=DauBep_Model.LayTenTTMA("1", langid)%></option>
                            <option value="all"><%=all%></option>
                            <%  } else {%>
                            <option value="all"><%=all%></option>
                            <option value="1"><%=DauBep_Model.LayTenTTMA("1", langid)%></option>
                            <option value="2"><%=DauBep_Model.LayTenTTMA("2", langid)%></option>
                            <option value="3"><%=DauBep_Model.LayTenTTMA("3", langid)%></option>
                            <%    }
                            %>
                        </select>
                    </th>
                </tr>
            </thead>
            <tbody>
                <%
                            for (int i = 0; i < v.size(); i++) {
                                Beans.DauBep b = (Beans.DauBep) v.elementAt(i);
                                total = total + 1;
                %>
                <tr>
                    <td><input type="checkbox" onclick="CheckboxCook()" class="<%=b.getMaCTHDT()%>" name="chkcook" value="<%=b.getMaMA()%>" alt="<%=b.getSoLuong()%>" id="<%=b.getMaDVT()%>" lang="<%=b.getGhiChu()%>"></td>
                    <td><%=b.getNgayGio()%></td>
                    <td><%=b.getTenKV()%></td>
                    <td><%=b.getTenBan()%></td>
                    <td><%=b.getTenMA()%></td>
                    <td><%=b.getTenDVT()%></td>
                    <td><%=b.getSoLuong()%></td>
                    <td style="padding-right: 5px;"><%=b.getGhiChu()%></td>
                    <td>
                        <%  if (b.getMaTTMA() == 1 || b.getMaTTMA() == 4) {%>
                        <div onclick="UpdateTTMACook(this.align, this.id, this.lang)" align="<%=b.getMaCTHDT()%>" lang="<%=msgright%>" id="1" class="ttmacook ttmacook1"  title="<%=DauBep_Model.LayTenTTMA("1", langid) %>" ></div>
                        <div onclick="UpdateTTMACook(this.align, this.id, this.lang)" align="<%=b.getMaCTHDT()%>" lang="<%=msgright%>" id="2" style="  opacity: 0.3;" class="ttmacook ttmacook2" title="<%=DauBep_Model.LayTenTTMA("2", langid)%>" ></div>
                        <div onclick="UpdateTTMACook(this.align, this.id, this.lang)" align="<%=b.getMaCTHDT()%>" lang="<%=msgright%>" id="3" style=" opacity: 0.3;" class="ttmacook ttmacook3"  title="<%=DauBep_Model.LayTenTTMA("3", langid)%>" ></div>
                            <%
                                                                                        if (b.getCoPhucVu() == 1) {%>
                        <div onclick="UpdateTTCook(0, this.id, this.lang, this.align)" align="<%=b.getMaCTHDT() %>" lang="<%=msgright%>" id="<%=b.getMaMA() %>" class="ttmacook" style="opacity: 0.30; margin-right: 0;"><img alt="" style="height: 18px; width: 18px; margin-top: 3px;" src="../images/del1.png"></div>
                            <%  } else {%>
                        <div onclick="UpdateTTCook(1, this.id, this.lang, this.align)" align="<%=b.getMaCTHDT() %>"  lang="<%=msgright%>" id="<%=b.getMaMA() %>" class="ttmacook" style=" margin-right: 0;"><img alt="" style="height: 18px; width: 18px; margin-top: 3px;" src="../images/del1.png"></div>
                            <%}%>
                            <%  } else {%>
                        <div onclick="UpdateTTMACook(this.align, this.id, this.lang)" align="<%=b.getMaCTHDT()%>" lang="<%=msgright%>" id="1"  style=" opacity: 0.30;" class="ttmacook ttmacook1" title="<%=DauBep_Model.LayTenTTMA("1", langid)%>" ></div>
                        <div onclick="UpdateTTMACook(this.align, this.id, this.lang)" align="<%=b.getMaCTHDT()%>" lang="<%=msgright%>" id="2"  style="opacity:1; " class="ttmacook ttmacook2" title="<%=DauBep_Model.LayTenTTMA("2", langid)%>" ></div>
                        <div onclick="UpdateTTMACook(this.align, this.id, this.lang)" align="<%=b.getMaCTHDT()%>" lang="<%=msgright%>" id="3" style="opacity: 0.30;" class="ttmacook ttmacook3"  title="<%=DauBep_Model.LayTenTTMA("3", langid)%>" ></div>

                            <%}%>
                    </td>
                </tr>
                <%}%>
            <input type="hidden" value="<%=total%>" id="total">
            <input type="hidden" value="<%=ng%>" alt="<%=ud1%>" id="SortNgayGioCook">
            <input type="hidden" value="<%=khuvucc%>" alt="<%=ud2%>"  id="SortKVCook">
            <input type="hidden" value="<%=ban%>" alt="<%=ud3%>" id="SortBanCook">
            <input type="hidden" value="<%=ma%>" alt="<%=ud4%>"  id="SortMACook">
            <input type="hidden" value="<%=dvt%>" alt="<%=ud5%>"  id="SortDVTCook">
            <input type="hidden" value="<%=sl%>" alt="<%=ud6%>"  id="SortSLCook">            
            </tbody>
        </table>
    </div>
</form>


